﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MODEL;

namespace DAL
{
    public class ClassService
    {
        /// <summary>
        /// 查询班级信息
        /// </summary>
        /// <returns></returns>
        public static DataTable ChaXunClass()
        {
            string sql = "select*from Class";

            DataTable dt = SqlHelper.QueryMethod(sql);
            return dt;

        }
        /// <summary>
        /// 有条件的查询班级信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static DataTable ChaXunClassName(string name )
        {

            string sql; 
            if (name=="")
            {
                sql = "select*from Class";
            }
            else 
            {
                sql= "select*from Class where C_No=@C_No or C_Name=@C_Name";
            }
            SqlParameter[] sp =
            {
                new SqlParameter("@C_No",name),
                new SqlParameter("@C_Name",name)
            };

            DataTable dt = SqlHelper.QueryMethod(sql, sp);
            return dt;

        }
        public static int ChaXunClassPwd(Class @class)
        {

            string sql = "select*from Class where C_No=@C_No and C_Name=@C_Name";
            SqlParameter[] sp =
            {
                new SqlParameter("@C_No",@class.C_No),
                new SqlParameter("@C_Name",@class.C_Name)
            };

            DataTable dt = SqlHelper.QueryMethod(sql, sp);
            int num = dt.Rows.Count;
            return num;

        }
    }
}
